package org.yzh.web.endpoint;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.yzh.protocol.commons.transform.attribute.AlarmDSM;
import org.yzh.protocol.commons.transform.attribute.AlarmJSATLl12;
import org.yzh.protocol.jsatl12.T9208;
import org.yzh.web.config.JtServerConfig;

import java.time.LocalDateTime;
import java.util.UUID;

@Component
public class MessageBuild {
    @Autowired
    private JtServerConfig jtServerConfig;

    public T9208 buildT9208(String clientId, AlarmJSATLl12 alarmJSATLl12) {
        T9208 t9208 = new T9208();
        t9208.setClientId(clientId);
        t9208.setIp(jtServerConfig.getIp());
        JtServerConfig.AlarmFileProperties alarmFile = jtServerConfig.getAlarmFile();
        t9208.setTcpPort(alarmFile.getPort());
        t9208.setUdpPort(alarmFile.getPort());
        t9208.setDeviceId(alarmJSATLl12.getDeviceId());
        t9208.setDateTime(alarmJSATLl12.getDateTime());
        t9208.setSequenceNo(alarmJSATLl12.getSequenceNo());
        t9208.setFileTotal(alarmJSATLl12.getFileTotal());
        t9208.setPlatformAlarmId(UUID.randomUUID().toString().replace("-", ""));
        return t9208;
    }
}
